#import <Cocoa/Cocoa.h>


// 9 sections of the square
typedef enum {
    BWGrid_NW,
    BWGrid_N,
    BWGrid_NE,
    BWGrid_W,
    BWGrid_Center,
    BWGrid_E,
    BWGrid_SW,
    BWGrid_S,
    BWGrid_SE,

    BWGrid_WholeSquare,
    BWGrid_InvalidSquare

} BWGrid_SquarePart;

#define BWGrid_NO_SQUARE (-1)
#define BWGrid_NO_TRANSIENT_VALUE (nanf("grid"))

typedef struct {
    int x;
    int y;
} BWGrid_Square;


@interface BWGrid : NSObject
{
    float fabricWidth;
    float transientFabricWidth;

    float fabricSpacing;
    float transientFabricSpacing; 

    NSColor *backgroundColor;
    NSColor *transientBackgroundColor;

    NSColor *threadColor;
    NSColor *transientThreadColor;
    float threadRed, threadGreen, threadBlue, threadAlpha;

    NSColor *edgeColor;
    NSColor *transientEdgeColor;
    float edgeWidth;

    BOOL flatGrid;
}

- (void) drawInRect: (NSRect) rect;

- (NSRect) rectForSquare: (BWGrid_Square) square
                    part: (BWGrid_SquarePart) part;

// BWGrid_InvalidSquare part if this doesn't map to a real square
- (void) mapPoint: (NSPoint) point
         toSquare: (BWGrid_Square *) square
             part: (BWGrid_SquarePart *) part
  forceCenterOnly: (BOOL) forceCenterOnly;

- (void) setFabricWidth: (float) newWidth;
- (float) fabricWidth;

- (void) setTransientFabricWidth: (float) newWidth;
- (float) transientFabricWidth;

- (void) setFabricSpacing: (float) newSpacing;
- (float) fabricSpacing;

- (void) setTransientFabricSpacing: (float) newSpacing;
- (float) transientFabricSpacing;

- (void) setBackgroundColor: (NSColor *) backgroundColor;
- (NSColor *) backgroundColor;

- (void) setTransientBackgroundColor: (NSColor *) backgroundColor;
- (NSColor *) transientBackgroundColor;

- (void) setThreadColor: (NSColor *) threadColor;
- (NSColor *) threadColor;

- (void) setTransientThreadColor: (NSColor *) threadColor;
- (NSColor *) transientThreadColor;

- (void) setEdgeColor: (NSColor *) edgeColor;
- (NSColor *) edgeColor;

- (void) setTransientEdgeColor: (NSColor *) edgeColor;
- (NSColor *) transientEdgeColor;

- (void) setEdgeWidth: (float) newWidth;
- (float) edgeWidth;

- (void) setFlatGrid: (BOOL) onOff;

- (BOOL) flatGrid;

@end // BWGrid

